#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Paul F. Idstein.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
news.py

Definition of the models for news tracking
"""
from google.appengine.ext import db
from google.appengine.ext.db import polymodel
from google.appengine.api import users
import model

class News(polymodel.PolyModel):
	type = db.TextProperty()
	timestamp = db.DateTimeProperty()
	editor = users.UserProperty()
	category = db.CategoryProperty()
	wave = db.ReferenceProperty(model.Wave)

class WaveletNews(News):
	wavelet = db.ReferenceProperty(model.Wavelet)
	waveletRevision = db.ReferenceProperty(model.WaveletRevision)
	
class WaveletNewsBlipCreated(WaveletNews):
	createdBlip = db.ReferenceProperty(model.Blip)

class WaveletNewsBlipRemoved(WaveletNews):
	removedBlip = db.ReferenceProperty(model.Blip)

class WaveletNewsParticipantsChanged(WaveletNews):
	participantsAdded = db.ListProperty(users.UserProperty)
	participantsRemoved = db.ListProperty(users.UserProperty)

class WaveletNewsTitleChanged(WaveletNews):
	newTitle = db.TextProperty()

class BlipNews(News):
	 blip = db.ReferenceProperty(model.Blip)
	 blipRevision = db.ReferenceProperty(model.BlipRevision)
	
class BlipNewsContributorsChanged(BlipNews):
	contributorsAdded = db.ListProperty(users.UserProperty)
	contributorsRemoved = db.ListProperty(users.UserProperty)

class BlipNewsSubmitted(BlipNews):
	newBlipRevision = db.ReferenceProperty(model.BlipRevision)

class BlipNewsAnnotatedTextChanged(BlipNews):
	annotation = db.TextProperty()
	annotationRevision = db.TextProperty()